package io.github.stary1993.kite.admin.config;


import io.github.stary1993.kite.core.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = AccessDeniedException.class)
    public R handleException(AccessDeniedException e) {
        log.error("全局异常信息{}", e.getClass());
        // 返回自定义的错误信息
        return R.failed(403, e.getMessage());
    }
}
